// Morrison 2009 IO

// Load original dataset
clear
use "M2009 IO Rep Data.dta"

// REPLICATION
summarize
count
egen excluded = rowmiss(countrycode-anocracy)
count if excluded == 0
display c(k)
mdesc
codebook year
codebook bankscode
gen elnincome = exp(lnincome)
summarize

// Table 3, Model 1
logit politydv  l.grantspc l.otherpc l.soepc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)
codebook year if e(sample)
codebook bankscode if e(sample)

// Table 3, Model 2
logit politydv  l.nontaxtotalpc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)
codebook year if e(sample)
codebook bankscode if e(sample)

// Table 3, Model 3
gen politynontax = polity2*nontaxtotalpc
logit politydv l.nontaxtotalpc l.polity2 l.politynontax gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)
codebook year if e(sample)
codebook bankscode if e(sample)

//IMPUTATION
// m = 40
clear
use "M2009 IO Imp Data.dta"
summarize

mi import flong, m(imp) id(bankscode year) imp(age65-tradegdp polity-lpolity)

gen tenplus = 0
gen time0 = 0
gen leadgone = 0
mi stset, clear
mi xtset bankscode year
sort bankscode year

//Table 3, Model 1
mi estimate, post: logit politydv  lgrantspc lotherpc lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 2
mi estimate, post: logit politydv  lnontaxtotalpc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 3
mi estimate, post: logit politydv lnontaxtotalpc lpolity2 lpolitynontax gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// m = 5
clear
use "M2009 IO Imp Data 5.dta"
summarize

mi import flong, m(imp) id(bankscode year) imp(age65-tradegdp polity-lpolity)

gen tenplus = 0
gen time0 = 0
gen leadgone = 0
mi stset, clear
mi xtset bankscode year
sort bankscode year

//Table 3, Model 1
mi estimate, post: logit politydv  lgrantspc lotherpc lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 2
mi estimate, post: logit politydv  lnontaxtotalpc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 3
mi estimate, post: logit politydv lnontaxtotalpc lpolity2 lpolitynontax gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// m = 90
clear
use "M2009 IO Imp Data 94.dta"
summarize

mi import flong, m(imp) id(bankscode year) imp(age65-tradegdp polity-lpolity)

gen tenplus = 0
gen time0 = 0
gen leadgone = 0
mi stset, clear
mi xtset bankscode year
sort bankscode year

//Table 3, Model 1
mi estimate, post: logit politydv  lgrantspc lotherpc lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 2
mi estimate, post: logit politydv  lnontaxtotalpc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 3
mi estimate, post: logit politydv lnontaxtotalpc lpolity2 lpolitynontax gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// HD
clear
use "M2009 IO Imp Data HD.dta"
summarize

mi import flong, m(imp) id(bankscode year) imp(age65-tradegdp polity-lpolity)

gen tenplus = 0
gen time0 = 0
gen leadgone = 0
mi stset, clear
mi xtset bankscode year
sort bankscode year

//Table 3, Model 1
mi estimate, post: logit politydv  lgrantspc lotherpc lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 2
mi estimate, post: logit politydv  lnontaxtotalpc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 3
mi estimate, post: logit politydv lnontaxtotalpc lpolity2 lpolitynontax gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// MICE
clear
use "M2009 IO Imp Data MICE.dta"
summarize

mi import flong, m(imp) id(bankscode year) imp(age65-tradegdp polity-lpolity)

gen tenplus = 0
gen time0 = 0
gen leadgone = 0
// mi stset, clear
mi xtset bankscode year
sort bankscode year

//Table 3, Model 1
mi estimate, post: logit politydv  lgrantspc lotherpc lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 2
mi estimate, post: logit politydv  lnontaxtotalpc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
//Table 3, Model 3
mi estimate, post: logit politydv lnontaxtotalpc lpolity2 lpolitynontax gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)
